<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}
</head>
<body>

{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <style>
          #logopic{
              width: 82px;
              height: 34px;
              position: absolute;
              left: 0;
              top: 0;
              opacity: 0;
              cursor: pointer;
          }

        </style>
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:&nbsp;</li>
                <li><a href="#">系统管理</a></li>
                <li class="active" style="color: #02b87f;"> 商户信息</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-body">

                <div class="alert alert-danger" role="alert">
                    设置后使用创建卡券等功能时系统将自动引用该信息。
                </div>
                <form class="form-horizontal" name="form" id="form" style="max-width: 900px;">
                    <div class="form-group">
                        <label class="control-label col-sm-3">商户名称：</label>
                        <div class="col-sm-9">
                            <p class="ng-binding">{$moinfo.merchant_name}</p>
                        </div>
                    </div>
                    <!--<div class="form-group">-->
                        <!--<label class="control-label col-sm-3">商户LOGO：</label>-->
                        <!--<div class="col-sm-9">-->
                            <!--<input type="text" class="form-control"-->
                                   <!--value="{$moinfo.img}">-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="form-group">
                        <label class="control-label col-sm-3">商户LOGO：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                        <div class="col-sm-9">
                            <img src="{$moinfo.img}" alt="" class="logopic-img" style="margin-top: 10px;width: 100px;height: 100px;border: none;display: block;"/>
                            <div class="ng-scope" style="position: relative;">
                                <span class="btn btn-default">上传</span>
                                <input type="file" id="logopic" value=""  onchange="upload('logopic', 'file')"/>
                                <input type="hidden" name="img" id="logopic-img" value="{$moinfo.img}" >
                                <input type="hidden" name="img_abs" id="logopic-img_abs" value="{$moinfo.img_abs}" >
                            </div>
                            <div class="r-desc ng-binding ng-scope">建议300*300像素 格式为.jpg</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3">联系人：</label>
                        <div class="col-sm-9">
                            <input name="contacts" type="text" class="form-control" value="{$moinfo.contacts}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3">联系电话：</label>
                        <div class="col-sm-9">
                            <input name="tel" type="text" class="form-control" value="{$moinfo.tel}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3">客服电话：</label>
                        <div class="col-sm-9">
                            <input name="cust_call" type="text" class="form-control" value="{$moinfo.cust_call}">
                        </div>
                    </div>
                    <div class="form-group text-center">
                        <button class="btn btn-default" id="sethy">保存</button>
                    </div>
                </form>
            </div>

        </div>

    {include file='public/footer'/}
    </div>
</section>

</body>


<script type="text/javascript">

    function upload(file, typed) {
        var formData = new FormData();
        formData.append('file', $('#' + file)[0].files[0]);
        formData.append('other', file);
        $.ajax({
            url: "{:url('uploads/upload')}",
            type: 'POST',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
        }).done(function (res) {
            console.log(res);
            if(res.code=="0"){
//
//            右侧预览图片
                $("." + file + "-img").attr("src", res.pic);
//            相应隐藏input传值
                $("#" + file + "-img_abs").val(res.pic);
                $("#" + file + "-img").val(res.loc_pic);
               // alert($('#logopic-img').attr("value"));
            }else{
                layer.alert(res.message);
            }
            // $("." + file).attr("src", res.savapath).css("display", "block");
            // $(".file-" + file).val(res.other);
            // $("." + typed + "-" + file).val(res.other);
        }).fail(function (res) {
            alert("上传失败")
        });
    };

</script>
<script type="text/javascript">
    var data=$('FormID').serialize();
    //序列化获得表单数据，结果为：user_id=12&user_name=John&user_age=20

    var submitData=decodeURIComponent(data,true);
    //submitData是解码后的表单数据，结果同上

        $("#sethy").click(function(){

            var $img_abs=$("img").attr("src");

                    $.ajax({
                        type: "POST",
                        url: "{:url('seting/momachinfo')}",
                        data: $('#form').serialize(),
                        success: function(data) {
                            console.log(data);
                            data = $.trim(data);
                            switch (data) {
                                case '0':
                                    alert('添加成功');
                                  //  window.location.replace()
                                    break;
                                case '1':
                                    alert('添加失败');

                                    break;
                                default:
                                    alert(data);
                            }

                            }
                        })


                });





</script>
</html>


